<template>
	<!-- 交货单入库 -->
	<view class>
		<view class="card-wrapper">
			<view class="radius shadow shadow-lg bg-white padding-sm light bg-blue main-wrap">
				<view class="flex flex-wrap">
					<view class="basis-xs">单据编号:</view>
					<view class="basis-xl text-black">{{ mainOrder.BILLNO }}</view>
				</view>
				
				<view class="" v-if="bstype == 0">
					<view class="flex flex-wrap">
						<view class="basis-xs">发货集团:</view>
						<view class="basis-xl text-black">{{ mainOrder.GROUPNAME }}</view>
					</view>
					<view class="flex flex-wrap">
						<view class="basis-xs">发货单位:</view>
						<view class="basis-xl text-black">{{ mainOrder.ORGNAME }}</view>
					</view>
					<view class="flex flex-wrap">
						<view class="basis-xs">发货部门:</view>
						<view class="basis-xl text-black">{{ mainOrder.DEPTNAME }}</view>
					</view>
					<view class="flex flex-wrap">
						<view class="basis-xs">收货单位:</view>
						<view class="basis-xl text-black">{{ mainOrder.SUPPLYNAME }}</view>
					</view>
					<view class="flex flex-wrap">
						<view class="basis-xs">仓库:</view>
						<view class="basis-xl text-black">{{ mainOrder.STORENAME }}</view>
					</view>
				</view>
				
				<view class="" v-else>
					<view class="flex flex-wrap">
						<view class="basis-xs">来源单号:</view>
						<view class="basis-xl text-black">{{ mainOrder.FRBILLNO }}</view>
					</view>
					<view class="flex flex-wrap">
						<view class="basis-xs">客户:</view>
						<view class="basis-xl text-black">{{ mainOrder.COMNAME }}</view>
					</view>
					<view class="flex flex-wrap">
						<view class="basis-xs">工地:</view>
						<view class="basis-xl text-black">{{ mainOrder.WORKSITE }}</view>
					</view>
					<view class="flex flex-wrap">
						<view class="basis-xs">备注:</view>
						<view class="basis-xl text-black">{{ mainOrder.VMEMO }}</view>
					</view>
				</view>
				
				<view class="flex flex-wrap">
					<view class="basis-xs">申请人:</view>
					<view class="basis-xl text-black">{{ mainOrder.CREATOR }}</view>
				</view>
				<view class="flex flex-wrap">
					<view class="basis-xs">单据日期:</view>
					<view class="basis-xl text-black">{{ mainOrder.BILLDATE }}</view>
				</view>

			</view>
			
			<!-- 物资子表 -->
			<view class="radius shadow shadow-lg bg-white padding-sm margin-top sub-table"
				v-for="(item,index) in planList" :key="index">
				<view class="flex flex-wrap">
					<view class="basis-xs">物资单号</view>
					<view class="basis-xl text-black">{{ item.PK_MATERIAL }}</view>
				</view>
				<view class="flex flex-wrap margin-top">
					<view class="basis-xs">物资名称</view>
					<view class="basis-xl text-black">
						{{ item.MATERIALNAME }}
					</view>
				</view>
				<view class="flex flex-wrap margin-top">
					<view class="basis-xs">物资规格</view>
					<view class="basis-xl text-black">{{ item.MATSPEC }}</view>
				</view>

				<view class="flex flex-wrap margin-top">
					<view class="basis-xs">申请数量</view>
					<view class="basis-xl text-black">{{ item.NNUMSQ }}/{{ item.UNIT || item.UNITNAME }}</view>
				</view>

				<view class="flex flex-wrap margin-top ">
					<view class="basis-xs"> {{ bstype==1?'出库数量':'入库数量' }} </view>
					<view class="basis-xl text-black" >{{ item.NNUM }} </view>
				</view>

				<!-- <view class="flex flex-wrap margin-top">
					<view class="basis-xs">入库日期</view>
					<view class="basis-xl text-black" >{{ item.INSTOCKDATE }} </view>
				</view> -->

				<view class="flex flex-wrap margin-top">
					<view class="basis-xs">备注</view>
					<view class="basis-xl text-black" >{{ item.VMEMO }} </view>	
				</view>

			</view>
		</view>

		<!-- <view class="operation">
			<view class="operation-button border-right" @click="finishSubmit">
				完成入库
			</view>
		</view> -->
	</view>

</template>
<script>
	import {
		mapState,
		mapMutations
	} from "vuex";
	import wPicker from "@/components/w-picker/w-picker.vue";
	import api from "@/common/api.js";
	import utils from "@/common/util.js";
	import modal from "@/components/modal/modal_print.vue";
	const plug = uni.requireNativePlugin('Html5app-Gprinter');
	let query = {
		category: "ST_INAPPLY",
		page: 1,
		rows: "50",
		sidx: "",
		sord: "",
		queryJson: {},
		userId: "",
		account: "admin"
	};
	let _self, dateTimekey, activeIndex, VMEMO, BILLFROM, ajaxUrl, activeType,
		qrcodeData = {
			number: 1
		};
	export default {
		computed: mapState(["userInfo", "taxRate", "wareType"]),
		data() {
			return {
				bstype: "",
				mainOrder: {},
				planList: [],
				isShowModal: false,
				isActiveNote: false,
				isActiveStore: false,
				mid: "",
				today: utils.getToDay(),
				dateTimekey: "",
				VMEMO: "",
				activeIndex: "",
				label01: "单号" // 主表的第一个label
			};
		},
		components: {
			wPicker,
			modal
		},
		onLoad(p) {
			console.log(p);
			_self = this;
			this.bstype = p.t;
			query.userId = _self.userInfo.UserId;
			query.account = _self.userInfo.Account;
			query.category = p.dbt == 1?"SUP_OUTSTOCK":"SUP_PURINSTORE"  ;
			let abc = JSON.parse(decodeURIComponent(p.item));
			_self.mainOrder = abc;
			console.log(this.mainOrder);
			query.queryJson.FRBILLNO = p.id;
			query.queryJson.BTYPE = 3
			query.FRBILLNO = p.id;
			_self.getDetail();
		},

		methods: {
			

			getDetail() {
				let URL = '/api/APPCommon/GetSaleCommitDetailsList';
				this.axios({
					url: URL,
					data: query,
					isLoading: 1
				}).then(res => {
					console.log(res);
					_self.planList = res.Result.rows ;
				})
			},
			submitPrint(item) {
				
			},
		}
	};
</script>

<style scoped lang="scss">
	.card-wrapper {
		padding: 26upx;
		padding-bottom: 100rpx;
	}
	.main-wrap .flex{
		padding: 20rpx 0;
	}
	.line-height-30 {
		line-height: 24px !important;
	}



	.sub-table-input {
		margin-top: 10upx;
	}
</style>
